package org.rdst.urchin.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.rdst.urchin.AJAXResult;
import org.rdst.urchin.bean.UserBean;
import org.rdst.urchin.service.UserService;
import org.rdst.urchin.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class testController {

    @Autowired
    private UserService userService;

    //测试获取所有用户信息


    @RequestMapping(method = RequestMethod.GET,value = "/getAllUsers")
    @ResponseBody
    public AJAXResult getUsers(@RequestParam(value = "name",required = false) String name){
        AJAXResult ajaxResult = new AJAXResult("222",250);
        System.out.println(ajaxResult);
        System.out.println("name"+name);
        return  ajaxResult;
    }

    @GetMapping("/te")
    @ResponseBody
    public UserBean test00(){
        UserBean userBean = new UserBean();
        userBean.setId(1);
        userBean.setCreateTime(123);
        userBean.setLevel("123213");
       return userBean;
    }

    @GetMapping("/st")
    public Object test01(){
        List<UserBean> userBeans= userService.getUsers();
        return  new AJAXResult(userBeans);
    }

}
